import { cityApi } from '../api'
// import * as TYPE from '../actionType/bannerType'

const state = {
	citylist: []
}

const getters = {
	citylist: state => state.citylist
}

const actions = {
	citylist({commit, state, rootState}) {
		rootState.requesting = true
		commit('CITY_LIST_REQUEST')
		cityApi.city().then((response) => {
			rootState.requesting = false
			commit('CITY_LIST_SUCCESS', response)
		}, (error) => {
			rootState.requesting = false
			commit('CITY_LIST_FAILURE')
		})
	}
}

const mutations = {
	['CITY_LIST_REQUEST'] (state) {

	},
	['CITY_LIST_SUCCESS'] (state, citylist) {
		state.citylist = citylist.data
	},
	['CITY_LIST_FAILURE'] (state) {

	}
}

export default {
	state,
	getters,
	actions,
	mutations
}